package it.nard.sourceframes;

import it.nard.controller.BasicController;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;

import org.dyno.visual.swing.layouts.Constraints;
import org.dyno.visual.swing.layouts.GroupLayout;
import org.dyno.visual.swing.layouts.Leading;
import org.jdesktop.swingx.JXDatePicker;

//VS4E -- DO NOT REMOVE THIS LINE!
public class GenerateReportPnl extends JPanel {

	private static final long serialVersionUID = 1L;
	private JCheckBox jCheckBox0;
	private JLabel jLabel1;
	private JXDatePicker jXDatePicker1;
	private JXDatePicker jXDatePicker0;
	private JLabel jLabel0;
	private JCheckBox jCheckBox1;
	private JCheckBox jCheckBox2;
	private JPanel jPanel0;
	private JButton jButton0;
	private BasicController basicController;
	private JCheckBox jCheckBox5;
	private JCheckBox jCheckBox4;
	private JCheckBox jCheckBox3;
	private JButton jButton1;
	private JTextField jTextField0;
	private JLabel jLabel2;
	private JTextArea jTextArea0;
	private JScrollPane jScrollPane0;
	public GenerateReportPnl() {
		initComponents();
	}
	public GenerateReportPnl(BasicController bc){
		initComponents();
		basicController = bc;
	}

	private void initComponents() {
		setLayout(new GroupLayout());
		add(getJPanel0(), new Constraints(new Leading(4, 791, 10, 10), new Leading(6, 591, 10, 10)));
		setSize(800, 600);
	}

	private JScrollPane getJScrollPane0() {
		if (jScrollPane0 == null) {
			jScrollPane0 = new JScrollPane();
			jScrollPane0.setViewportView(getJTextArea0());
		}
		return jScrollPane0;
	}
	public JTextArea getJTextArea0() {
		if (jTextArea0 == null) {
			jTextArea0 = new JTextArea();
			jTextArea0.setEditable(false);
		}
		return jTextArea0;
	}
	private JLabel getJLabel2() {
		if (jLabel2 == null) {
			jLabel2 = new JLabel();
			jLabel2.setText("Directory");
		}
		return jLabel2;
	}
	public JTextField getJTextField0() {
		if (jTextField0 == null) {
			jTextField0 = new JTextField();
			jTextField0.setEditable(false);
		}
		return jTextField0;
	}
	private JButton getJButton1() {
		if (jButton1 == null) {
			jButton1 = new JButton();
			jButton1.setText("Scegli dir.");
			jButton1.addActionListener(new ActionListener() {
	
				public void actionPerformed(ActionEvent event) {
					jButton1ActionActionPerformed(event);
				}
			});
		}
		return jButton1;
	}
	public JCheckBox getJCheckBox3() {
		if (jCheckBox3 == null) {
			jCheckBox3 = new JCheckBox();
			jCheckBox3.setText("Latte In Entrata");
		}
		return jCheckBox3;
	}
	public JCheckBox getJCheckBox4() {
		if (jCheckBox4 == null) {
			jCheckBox4 = new JCheckBox();
			jCheckBox4.setText("Latte In Giacenza");
		}
		return jCheckBox4;
	}
	public JCheckBox getJCheckBox5() {
		if (jCheckBox5 == null) {
			jCheckBox5 = new JCheckBox();
			jCheckBox5.setText("Latte In Uscita");
		}
		return jCheckBox5;
	}
	private JButton getJButton0() {
		if (jButton0 == null) {
			jButton0 = new JButton();
			jButton0.setText("Genera");
			jButton0.addActionListener(new ActionListener() {
	
				public void actionPerformed(ActionEvent event) {
					jButton0ActionActionPerformed(event);
				}
			});
		}
		return jButton0;
	}
	private JPanel getJPanel0() {
		if (jPanel0 == null) {
			jPanel0 = new JPanel();
			jPanel0.setBorder(BorderFactory.createTitledBorder(null, "Generazione  Automatica Reports", TitledBorder.LEADING, TitledBorder.DEFAULT_POSITION, null,
					null));
			jPanel0.setLayout(new GroupLayout());
			jPanel0.add(getJXDatePicker0(), new Constraints(new Leading(140, 10, 10), new Leading(1, 12, 12)));
			jPanel0.add(getJLabel0(), new Constraints(new Leading(17, 12, 12), new Leading(6, 10, 10)));
			jPanel0.add(getJCheckBox5(), new Constraints(new Leading(16, 118, 12, 12), new Leading(77, 12, 12)));
			jPanel0.add(getJCheckBox4(), new Constraints(new Leading(16, 132, 12, 12), new Leading(51, 12, 12)));
			jPanel0.add(getJCheckBox3(), new Constraints(new Leading(17, 115, 12, 12), new Leading(26, 12, 12)));
			jPanel0.add(getJXDatePicker1(), new Constraints(new Leading(399, 10, 10), new Leading(0, 12, 12)));
			jPanel0.add(getJLabel1(), new Constraints(new Leading(294, 105, 12, 12), new Leading(1, 27, 12, 12)));
			jPanel0.add(getJTextField0(), new Constraints(new Leading(83, 236, 12, 12), new Leading(107, 12, 12)));
			jPanel0.add(getJLabel2(), new Constraints(new Leading(21, 10, 10), new Leading(110, 12, 12)));
			jPanel0.add(getJScrollPane0(), new Constraints(new Leading(16, 757, 10, 10), new Leading(141, 392, 10, 10)));
			jPanel0.add(getJButton1(), new Constraints(new Leading(327, 10, 10), new Leading(104, 12, 12)));
			jPanel0.add(getJButton0(), new Constraints(new Leading(626, 101, 10, 10), new Leading(104, 28, 12, 12)));
			jPanel0.add(getJCheckBox0(), new Constraints(new Leading(171, 10, 10), new Leading(26, 12, 12)));
			jPanel0.add(getJCheckBox1(), new Constraints(new Leading(171, 86, 12, 12), new Leading(51, 12, 12)));
			jPanel0.add(getJCheckBox2(), new Constraints(new Leading(171, 86, 12, 12), new Leading(77, 12, 12)));
		}
		return jPanel0;
	}
	public JCheckBox getJCheckBox2() {
		if (jCheckBox2 == null) {
			jCheckBox2 = new JCheckBox();
			jCheckBox2.setText("Ricotta");
		}
		return jCheckBox2;
	}

	public JCheckBox getJCheckBox1() {
		if (jCheckBox1 == null) {
			jCheckBox1 = new JCheckBox();
			jCheckBox1.setText("Provola");
		}
		return jCheckBox1;
	}

	private JLabel getJLabel0() {
		if (jLabel0 == null) {
			jLabel0 = new JLabel();
			jLabel0.setText("Data Inizio Periodo");
		}
		return jLabel0;
	}

	public JXDatePicker getJXDatePicker0(){
	if(jXDatePicker0==null){
	jXDatePicker0 = new JXDatePicker();
		}
	return jXDatePicker0;
	}

	public JXDatePicker getJXDatePicker1(){
	if(jXDatePicker1==null){
	jXDatePicker1 = new JXDatePicker();
		}
	return jXDatePicker1;
	}

	private JLabel getJLabel1() {
		if (jLabel1 == null) {
			jLabel1 = new JLabel();
			jLabel1.setText("Data Fine Periodo");
		}
		return jLabel1;
	}

	public JCheckBox getJCheckBox0() {
		if (jCheckBox0 == null) {
			jCheckBox0 = new JCheckBox();
			jCheckBox0.setText("Mozzarella");
		}
		return jCheckBox0;
	}

	private void jButton0ActionActionPerformed(ActionEvent event) {
		this.basicController.select(null);
	}
	private void jButton1ActionActionPerformed(ActionEvent event) {
	
		JFileChooser fileChooser = new JFileChooser("~");
		fileChooser.setMultiSelectionEnabled(false);
		fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
		int choose = fileChooser.showOpenDialog(this);
		if(choose == JFileChooser.APPROVE_OPTION)
		{
			File directory = fileChooser.getSelectedFile();
			getJTextField0().setText(directory.getPath());
			
		}
		
	}

}
